#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

class Solution
{
public:
	string multiply(string num1, string num2)
	{
		reverse(num1.begin(), num1.end());
		reverse(num2.begin(), num2.end());
		
		int n1 = num1.size(), n2 = num2.size();
		
		//创建并初始化临时结果数组arr
		int arr[n1 + n2 - 1];
		for (auto& e : arr) e = 0;
		
		for (int i = 0; i < n1; ++i)
		{
			for (int j = 0; j < n2; ++j)
			{
				arr[i + j] += num1[i] * num2[j];
			}
		}
		//创建结果数组ret
		string ret;
		int sum = 0, tem = 0;
		for (int i = n1 + n2 - 2; i >= 0; --i)
		{
			//tem一定是一位数：因为两个一位数相乘的最大值81%10的结果是一位数
			sum = arr[i] + tem;
			
			tem = sum % 10;
			
			ret += tem + '0';
			
			tem /= 10;
		}
		if (tem != 0)
		{
			ret += tem + '0';
		}
		reverse(ret.begin(), ret.end());
		return ret;
	}
};

int main()
{
	string s = Solution().multiply("2","3");
	
	cout<<s<<endl;
	
	return 0;
}
